import QtQuick 1.0
//import ShellInvoker 1.0
import "../../../common/lib/kdeadmouseutils-build-desktop"

Rectangle {
      id:maiRect
      height: 200
      width:  500
      color:'#010101'
      border.color:'green'
      border.width:2
      //property variant dataProvider : Qt.createComponent("MovieModel.qml")
      Component {
	id: delegate
	Rectangle {
	  color:'#010101'
	  id:rectItem
	  width: 100
	  height: 300
	  //border.color:'green'
	  border.width:2
	  //transform: Rotation { id: rot ; origin.x: width/2; origin.y: 0; axis { x: 0; y: 1; z: 0 } angle:index>view.currentIndex?-30:30 }
	  
	  Image {
		//scale:PathView.iconScale
		//anchors.horizontalCenter: nameText.horizontalCenter
		fillMode: Image.PreserveAspectFit
		source: poster
		anchors.top:parent.top
		id:imgMain
		width:parent.width
		height:150
		smooth: true
	  }
	    
	  Image {
	      //scale:PathView.iconScale
	      //anchors.horizontalCenter: nameText.horizontalCenter
	      //anchors.fill : parent
	      rotation:180
	      anchors.top:imgMain.bottom
	      width:parent.width
	      height:parent.height/2
	      fillMode: Image.PreserveAspectFit
	      source: poster
	      smooth: true
	  }
	  Rectangle {
	      
	      anchors.top:imgMain.bottom
	      width:parent.width
	      height:parent.height/2
	      smooth: true
	      gradient: Gradient {
		  GradientStop { position: 0.0; color: "transparent" }
		  GradientStop { position: 0.3; color:parent.color }
	      }
	  }
	  
	  states: 
	    [	State {
		    name: "active"; when: activeFocus
		    PropertyChanges { target: rectItem;scale: 1.2}
		    //PropertyChanges { target: rot;angle: 0}
		    //PropertyChanges { target: lPosterId;currentIndex: numPoster}
		    
		    }
	      ,	State {
		    name: ""
		    PropertyChanges { target: rectItem;scale: 1}
		    PropertyChanges { target: rectItem;border.color: index>view.currentIndex?'red':'green'}
		    PropertyChanges { target: rot;angle:index>view.currentIndex?-30:30}
		    //PropertyChanges { target: lPosterId;currentIndex: numPoster}
		    
		    }
	      ]
	      
	      transitions: Transition {
		  NumberAnimation { properties: "scale"; duration: 100 }
		  NumberAnimation { properties: "angle"; duration: 100 }
		  NumberAnimation { properties: "border.color"; duration: 100 }
	      }
	  
	}
      }
      
     ListView {
	 id:view
	 focus:true
	 anchors.fill : parent
	 //highlightRangeMode:ListView.StrictlyEnforceRange
	 //preferredHighlightBegin: 0; preferredHighlightEnd: 0
	 //highlightFollowsCurrentItem: true
	 orientation : ListView.Horizontal
	 //cacheBuffer : width * 2
	 spacing:20
	 //property variant dataProvider : Qt.createComponent("MovieModel.qml")
	 property variant dataProvider : MovieModel{}
         model: dataProvider.model
         delegate: delegate
         onCurrentIndexChanged : positionViewAtIndex ( currentIndex, ListView.Center )
         //Component.onCompleted : positionViewAtIndex ( currentIndex, ListView.Center )
	 
     }
     
     
}

 
